//*********************************************************
//
//    Copyright (c) Microsoft. All rights reserved.
//    This code is licensed under the Apache License, Version 2.0.
//    THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
//    ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
//    IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
//    PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

namespace Microsoft.Research.DataLayer
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// 
    /// </summary>
    public interface IDataLayerSecurityBeforeCalls
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="error">The error.</param>
        /// <param name="storage">Object type to operate on.</param>
        /// <param name="action">Action to perform on the object.</param>
        /// <param name="paramList">The parameters on original request.</param>
        /// <returns></returns>
        SecurityAction Object(
            out Exception error,
            ref Connection.Storage storage, ref Connection.Action action,
            ref List<Parameter> paramList);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="error">The error.</param>
        /// <param name="storage">Object type to operate on.</param>
        /// <param name="action">Action to perform on the object.</param>
        /// <param name="creator">Delegate function to build objects from data.</param>
        /// <param name="results">List of objects constructed using ObjectCreator function.</param>
        /// <returns></returns>
        SecurityAction Object(
            out Exception error,
            ref Connection.Storage storage, ref Connection.Action action,
            Connection.ObjectCreator creator, ref List<IObject> results);

        /// <summary>
        /// Perfoms an action on a relationship between two objects
        /// </summary>
        /// <param name="action">Action to perform</param>
        /// <param name="obj1">First object in the relation</param>
        /// <param name="obj2">Second object in the relation</param>
        SecurityAction Relation(
            out Exception error, ref Connection.Action action, ref IObject obj1, ref IObject obj2);

        /// <summary>
        /// Perfoms an action on a relationship between two objects
        /// </summary>
        /// <param name="action">Action to perform</param>
        /// <param name="obj1">First object in the relation</param>
        /// <param name="obj2">Second type in the relation</param>
        /// <param name="revKey">Foreign key field</param>
        /// <param name="paramList"></param>
        SecurityAction Relation(
            out Exception error, ref Connection.Action action, ref IObject obj1,
            ref Connection.Storage obj2, ref string revKey, ref List<Parameter> paramList);

        /// <summary>
        /// Performs an action on a stored (or to be stored) relation in the backend and returns
        /// results of the operation to the caller.
        /// </summary>
        /// <param name="action">Action to perform</param>
        /// <param name="obj1">First object in the relation</param>
        /// <param name="obj2Type">Type of the second object in the relation</param>
        /// <param name="creator">Delegate function to build relationship object from data</param>
        /// <param name="results">List of objects constructed using ObjectCreator function</param>
        SecurityAction Relation(
            out Exception error, ref Connection.Action action, ref IObject obj1,
            ref Connection.Storage obj2Type, Connection.ObjectCreator creator, ref List<IObject> results);

        /// <summary>
        /// Performs an action on a stored (or to be stored) relation in the backend and returns
        /// results of the operation to the caller.
        /// </summary>
        /// <param name="action">Action to perform</param>
        /// <param name="obj1">First object in the relation</param>
        /// <param name="obj2Type">Type of the second object in the relation</param>
        /// <param name="creator">Delegate function to build relationship object from data</param>
        /// <param name="results">List of objects constructed using ObjectCreator function</param>
        /// <param name="field">Name of the field to search on (for multiple relationships against the same entity)</param>
        SecurityAction Relation(out Exception error, ref Connection.Action action, ref IObject obj1,
            ref string field, ref Connection.Storage obj2Type, Connection.ObjectCreator creator, ref List<IObject> results);

    }

}
